package com.spring.event.spring.service;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

//@Component
public class MyApplicationEventService implements ApplicationListener<ApplicationEvent> {

    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        System.out.println("事件发生:"+event.getClass().getName());
       /* if(event instanceof ContextClosedEvent){
            System.out.println(event.getClass().getSimpleName()+" 事件已发生！");
        }else if(event instanceof ContextRefreshedEvent){
            System.out.println(event.getClass().getSimpleName()+" 事件已发生！");
        }else if(event instanceof ContextStartedEvent){
            System.out.println(event.getClass().getSimpleName()+" 事件已发生！");
        }else if(event instanceof ContextStoppedEvent){
            System.out.println(event.getClass().getSimpleName()+" 事件已发生！");
        }else{
            System.out.println("有其它事件发生:"+event.getClass().getName());
        }*/

    }


}


